package org.longteng.mobileluck.controller;

import lombok.extern.slf4j.Slf4j;
import org.longteng.sys.ComputerInfoUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * 页面mvc  action
 */
@Controller
@Slf4j
public class ThyMobileLuckController {

    @RequestMapping("/thymeleaf")
    public String helloThymeleaf(Model model){
        log.debug("helloThymeleaf.");
        model.addAttribute("hello","hello Thymeleaf！");
        return "hello/index";
    }


    /**
     * 到手机号吉祥测算页面
     * @param model
     * @param request
     * @return
     */
    @RequestMapping("/mobileluck")
    public String mobileluckPage(Model model, HttpServletRequest request){
        String openid = request.getParameter("openid");
        model.addAttribute("hello","hello Thymeleaf！");
        log.info("到手机号吉祥测算页面,openid:{}", openid);

        return "mobilepage/mobileluck";
    }

    /**
     * 拍到手机选号上传-帮助吉祥选号页面
     * @param model
     * @param request
     * @return
     */
    @RequestMapping("/mobilepic")
    public String mobileSelImgPage(Model model, HttpServletRequest request){
        String openid = request.getParameter("openid");
        boolean clientIsMoblie = ComputerInfoUtil.clientIsMoblie(request); // 是否手机端
        model.addAttribute("clientIsMoblie",clientIsMoblie);
        log.info("到手机选号上传-帮助吉祥选号页面,clientIsMoblie:{}", clientIsMoblie);

        return "mobilepage/mobile_img_upload";
    }

}
